package io.finer.erp.jeecg.stock.service.impl;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.api.client.util.Maps;
import com.google.common.collect.Lists;

import cn.hutool.core.collection.CollUtil;
import io.finer.erp.jeecg.bas.entity.BasMaterialCategory;
import io.finer.erp.jeecg.bas.service.IBasMaterialCategoryService;
import io.finer.erp.jeecg.stock.entity.PurchaseOrderEntry;
import io.finer.erp.jeecg.stock.mapper.PurchaseOrderEntryMapper;
import io.finer.erp.jeecg.stock.service.IPurchaseOrderEntryService;

/**
 * @Description: 明细
 * @Author: jeecg-boot
 * @Date:   2021-05-20
 * @Version: V1.0
 */
@Service
public class PurchaseOrderEntryServiceImpl extends ServiceImpl<PurchaseOrderEntryMapper, PurchaseOrderEntry> implements IPurchaseOrderEntryService {
	
	@Autowired
	private PurchaseOrderEntryMapper purchaseOrderEntryMapper;
	@Autowired
	private IBasMaterialCategoryService categoryService;
	
	@Override
	public List<PurchaseOrderEntry> selectByMainId(String mainId) {
		List<PurchaseOrderEntry> list = purchaseOrderEntryMapper.selectByMainId(mainId);
//		if(CollUtil.isNotEmpty(list)) {
//			List<String> cateIds = Lists.newArrayList();
//			for (PurchaseOrderEntry entry : list) {
//				cateIds.add(entry.getMaterialId());
//			}
//			List<BasMaterialCategory> cateList = categoryService.lambdaQuery().in(BasMaterialCategory::getId, cateIds).list();
//			if(CollUtil.isNotEmpty(cateList)) {
//				Map<String, String> nameMap = Maps.newHashMap();
//				for (BasMaterialCategory cate : cateList) {
//					nameMap.put(cate.getId(), cate.getName());
//				}
//			}
//		}
		
		return list;
	}
}
